
app.controller('newParametersCtrl', function($element, $scope, $state, rest, user, uploadConf, tipService, $window, $rootScope) {
	//$scope.myUpMenus = angular.copy($scope.ngDialogData, {});
	//$scope.menuLookup = $scope.myUpMenus.datas[0];  //设置默认所属菜单为第一个 请选择
	
	//新建$scope.iNowData全默认为空
	$scope.iNowData = {
		"paramKey":"",
		"paramValue":"",
		"remark":""
	};
    //保存
    $scope.preserveSubmit = function(){
    	var formData = {
    		"key" : $scope.iNowData.paramKey,  
    		"value" : $scope.iNowData.paramValue,  
    		"remark" : $scope.iNowData.remark  //排序字符
    	}
    	var btn = true;  //提交开关
    	//非空校验
    	if($scope.iNowData.paramKey == ""){
    		layer.tips('参数名称必填', '.paramKey-Tips',{
			  tipsMore: true,
			  tips: [2,'#ed5565']
			});
    		btn =  false;
    	};
    	if($scope.iNowData.paramValue == ""){
    		layer.tips('参数内容必填', '.paramValue-Tips',{
			  tipsMore: true,
			  tips: [2,'#ed5565']
			});
    		btn =  false;
    	};
    	
    	//console.log($scope.iNowData.menuName == "",$scope.iNowData.tagName == "",$scope.iNowData.sort == "",$scope.iNowData.menuPath == "",$scope.iNowData.menuType == "")
    	if(btn){
    		var token = $window.localStorage.getItem("token");
    		rest.decoJava({
    			type: 'post',
	            url: '/tenancy-sys/admin/systemConf/add',
	            data: formData,
	            beforeSend: function(request){
					request.setRequestHeader("token", token); 
				},
	            success: function (result) {
	            	console.log(result);
	            	layer.closeAll('loading');
	                if (result) {
	                    if ("0000" == result.code) {
							layer.msg(result.message, {
					        	offset:'t',
					        	icon: 1,
								time: 0, //不自动关闭
								btn: ['确定'],
								yes: function(index){
									layer.close(index);
									$scope.closeThisDialog();
							    }
							});
	                    } else {
	                    	layer.msg(result.message,{
			    				offset:'t'
			    			});
	                    }
	                }
	            }
	        });
    	}
    };
    
    $scope.hideBtn = function(){
    	$scope.closeThisDialog();
    }
    
});
